package com.example.vote.config;

import com.example.vote.api.MatchAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor;

/**
 * Created with IntelliJ IDEA.
 * ClassName: WebConfig
 * Package: com.example.vote.config
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-06-29
 * Time: 18:59
 */

@CacheConfig
@EnableWebSocket
public class WebConfig implements WebSocketConfigurer {

    @Autowired
    private MatchAPI matchAPI;

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(matchAPI,"/findMatch")
                .addInterceptors(new HttpSessionHandshakeInterceptor());
    }
}
